package com.xxxt.hrs.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xxxt.dao.StudentMapper;
import com.xxxt.entity.Student;
import com.xxxt.hrs.service.StudentService;
@Service
@Transactional
public class StudentServiceImpl implements StudentService{
@Autowired
private StudentMapper studentMapper;

@Override
public boolean addOneStudent(Student student) {
	//判断学生是否存在,存在：true 不存在false
	boolean studentIsExist = this.studentIsExist(student.getSno());
	if(studentIsExist==false) {
		studentMapper.addStudent(student);
		return true;
	}
		return false;
}

@Override
public boolean studentIsExist(String sno) {
	Student studentIsExist = studentMapper.studentIsExist(sno);
	if(studentIsExist==null) {
		return false;
	}
		return true;
}

@Override
public PageInfo<Student> queryClassGradeByClassGradeIdWithPage(int pageNum, int pageSize, String classGradeId) {
	PageHelper.startPage(pageNum, pageSize);
	List<Student> queryStudentByClassGrade = studentMapper.queryStudentByClassGrade(classGradeId);
	PageInfo<Student>  pageStudents=new PageInfo<Student> (queryStudentByClassGrade);
	return pageStudents;
}

@Override
public PageInfo<Student> queryManyStudentByNameLikeWithPage(int pageNum, int pageSize, String name) {
	PageHelper.startPage(pageNum, pageSize);
	List<Student> queryManyStudentByNameLike = studentMapper.queryManyStudentByNameLike(name);
	PageInfo<Student>  pageStudents=new PageInfo<Student> (queryManyStudentByNameLike);
	return pageStudents;
}

@Override
public PageInfo<Student> queryStudentByGradeWithPage(int pageNum, int pageSize, String gradeId) {
	PageHelper.startPage(pageNum, pageSize);
	List<Student> queryStudentByGrade = studentMapper.queryStudentByGrade(gradeId);
	PageInfo<Student>  pageStudents=new PageInfo<Student> (queryStudentByGrade);
	return pageStudents;
}

@Override
public PageInfo<Student> queryStudentBySpecialtyWithPage(int pageNum, int pageSize, String specialtyId) {
	PageHelper.startPage(pageNum, pageSize);
	List<Student> queryStudentBySpecialty = studentMapper.queryStudentBySpecialty(specialtyId);
	PageInfo<Student>  pageStudents=new PageInfo<Student> (queryStudentBySpecialty);
	return pageStudents;
}

@Override
public PageInfo<Student> queryStudentByCollegeWithPage(int pageNum, int pageSize, String collegeId) {
	PageHelper.startPage(pageNum, pageSize);
	List<Student> queryStudentByCollege = studentMapper.queryStudentByCollege(collegeId);
	PageInfo<Student>  pageStudents=new PageInfo<Student> (queryStudentByCollege);
	return pageStudents;
}

@Override
public PageInfo<Student> queryStudentBySchoolWithPage(int pageNum, int pageSize, String schoolId) {
	PageHelper.startPage(pageNum, pageSize);
	List<Student> queryStudentBySchool = studentMapper.queryStudentBySchool(schoolId);
	PageInfo<Student>  pageStudents=new PageInfo<Student> (queryStudentBySchool);
	return pageStudents;
}

@Override
public PageInfo<Student> queryStudentByNameAndClassGradeWithPage(int pageNum, int pageSize, String name, String classGradeId) {
	PageHelper.startPage(pageNum, pageSize);
	List<Student> queryStudentByNameAndClassGrade = studentMapper.queryStudentByNameAndClassGrade(name, classGradeId);
	PageInfo<Student>  pageStudents=new PageInfo<Student> (queryStudentByNameAndClassGrade);
	return pageStudents;
}

@Override
public PageInfo<Student> queryStudentByNameAndGradeWithPage(int pageNum, int pageSize, String name, String gradeId) {
	PageHelper.startPage(pageNum, pageSize);
	List<Student> queryStudentByNameAndGrade = studentMapper.queryStudentByNameAndGrade(name, gradeId);
	PageInfo<Student>  pageStudents=new PageInfo<Student> (queryStudentByNameAndGrade);
	return pageStudents;
}

@Override
public PageInfo<Student> queryStudentByNameAndSpecialtyWithPage(int pageNum, int pageSize, String name,
		String specialtyId) {
	PageHelper.startPage(pageNum, pageSize);
	List<Student> queryStudentByNameAndSpecialty = studentMapper.queryStudentByNameAndSpecialty(name, specialtyId);
	PageInfo<Student>  pageStudents=new PageInfo<Student> (queryStudentByNameAndSpecialty);
	return pageStudents;
}

@Override
public PageInfo<Student> queryStudentByNameAndCollegeWithPage(int pageNum, int pageSize, String name,
		String collegeId) {
	PageHelper.startPage(pageNum, pageSize);
	List<Student> queryStudentByNameAndCollege = studentMapper.queryStudentByNameAndCollege(name, collegeId);
	PageInfo<Student>  pageStudents=new PageInfo<Student> (queryStudentByNameAndCollege);
	return pageStudents;
}

@Override
public PageInfo<Student> queryStudentByNameAndSchoolWithPage(int pageNum, int pageSize, String name, String schoolId) {
	PageHelper.startPage(pageNum, pageSize);
	List<Student> queryStudentByNameAndSchool = studentMapper.queryStudentByNameAndSchool(name, schoolId);
	PageInfo<Student>  pageStudents=new PageInfo<Student> (queryStudentByNameAndSchool);
	return pageStudents;
}

@Override
public PageInfo<Student> queryStudentByCompanyWithPage(int pageNum, int pageSize, String companyId) {
	PageHelper.startPage(pageNum, pageSize);
	List<Student> queryStudentByCompany = studentMapper.queryStudentByCompany(companyId);
	PageInfo<Student>  pageStudents=new PageInfo<Student> (queryStudentByCompany);
	return pageStudents;
}

@Override
public PageInfo<Student> queryStudentWithInternshipWithPage(int pageNum, int pageSize, String tno) {
	PageHelper.startPage(pageNum, pageSize);
	List<Student> queryStudentWithInternship = studentMapper.queryStudentWithInternship(tno);
	PageInfo<Student> pageStudents=new PageInfo<Student> (queryStudentWithInternship);
	return pageStudents;
}

@Override
public PageInfo<Student> queryStudentWithNoInternshipWithPage(int pageNum, int pageSize, String tno) {
	PageHelper.startPage(pageNum, pageSize);
	List<Student> queryStudentWithNoInternship = studentMapper.queryStudentWithNoInternship(tno);
	PageInfo<Student> pageStudents=new PageInfo<Student> (queryStudentWithNoInternship);
	return pageStudents;
}

}
